package com.pentajock.docdb.types;

import java.util.*;

public class DocumentProperties {
	private HashMap<String, String> propertyMap;
	private boolean propertiesLocked;
	
	public DocumentProperties() {
		propertyMap = new HashMap<String, String>();
		propertiesLocked = false;
	}

	public String getProperty(String propertyName) {
		return propertyMap.get(propertyName);
	}
	
	public boolean setProperty(String propertyName, String value) {
		if(!propertiesLocked) {
			propertyMap.put(propertyName, value);
			return true;
		}
		return false;
	}
	
	public void lockProperties() {
		propertiesLocked = true;
	}
	
	public Map<String, String> asMap() {
		return propertyMap;
	}
	
	/*
	 * DocumentProperties test:
	 *
	Document doc = (Document)resultList.getSelectedValue();
	java.util.List<String> deptProps = null;
	try {
		DBClient.printDebug("DOCUMENT PROPERTIES AND VALUES:");
		deptProps = DBController.getDepartmentProperties(doc.getDepartmentName());
		for(String property : deptProps) {
			DBClient.printDebug(property + ":=" + doc.getProperty(property));
		}
		DBClient.printDebug("---------------------------------");
	}
	catch(SQLException ex) {
		DBClient.printStackTrace(ex, "Error grabbing DepartmentProperties.");
	}
	/**/
	/*
	 * DepartmentProperties test:
	 *
	DepartmentProperties props = null;
	try {
		DBClient.printDebug("FULL DEPARTMENT SPECIFIC PROPERTIES:");
		props = DBController.getDepartmentPropertiesFull(doc.getDepartmentName());
		for(String propertyName : deptProps) {
			DBClient.printDebug(props.getProperty(propertyName).toString());
		}
		DBClient.printDebug("---------------------------------");
	}
	catch(SQLException ex) {
		DBClient.printStackTrace(ex, "Error grabbing DepartmentProperties.");
	}
	/**/
	
}
